<template>
	<view>
		<web-view style="width: 100vw;height: 100vh;" :src="src" @message="onMessage"></web-view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				src: ''
			};
		},
		onLoad(option) {
			this.src = option.url;
		},
		methods: {
			onMessage(e) {
				// 当webview内页面加载完成时，发送指令
				if (e.detail.data.action === 'loaded') {
					this.postMessageToWebView({
						action: 'playVideo'
					});
				}
			},
			postMessageToWebView(data) {
				this.$refs.webview.postMessage(data);
			}
		}
	};
</script>